package net.koodar.forge.system.role.manager;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import net.koodar.forge.system.role.dao.RoleMenuMapper;
import net.koodar.forge.system.role.model.entity.RoleMenu;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

/**
 * @author liyc
 */
@Service
@RequiredArgsConstructor
public class RoleMenuManager extends ServiceImpl<RoleMenuMapper, RoleMenu> {

    public List<RoleMenu> findByRoleId(Long roleId) {
        return baseMapper.selectList(Wrappers.<RoleMenu>lambdaQuery().eq(RoleMenu::getRoleId, roleId));
    }

    public List<RoleMenu> findListByRoleIdIn(Collection<Long> roleIds) {
        return baseMapper.selectList(Wrappers.<RoleMenu>lambdaQuery().in(RoleMenu::getRoleId, roleIds));
    }

    public List<RoleMenu> findByMenuId(Long menuId) {
        return baseMapper.selectList(Wrappers.<RoleMenu>lambdaQuery().eq(RoleMenu::getMenuId, menuId));
    }
}
